package com.nineclock.auth.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;

@Configuration
public class TokenConfig {

    @Value("${nineclock.auth.signKey}")
    private String SING_KEY ;

    @Bean
    public JwtAccessTokenConverter jwtAccessTokenConverter(){
        JwtAccessTokenConverter tokenConverter = new JwtAccessTokenConverter();
        //设置密钥
        tokenConverter.setSigningKey(SING_KEY);
        return tokenConverter;
    }

    @Bean
    public TokenStore tokenStore(){
        //在内存中存储token（简单的令牌）  InMemoryTokenStore
        // jwt token令牌
        JwtAccessTokenConverter tokenConverter = jwtAccessTokenConverter();
        System.out.println(tokenConverter);
        return new JwtTokenStore(tokenConverter);
    }



}